using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL
{

    /// <summary>
    /// The StudentProfileTableManager class is responsible for managing BO.StudentProfileTable objects in the system.
    /// </summary>
    [DataObjectAttribute()]
    public class StudentProfileTableManager
    {

        #region "Public Methods"

        /// <summary>
        /// Gets a list with all StudentProfileTable objects in the database.
        /// </summary>
        /// <returns>A list with all StudentProfileTable from the database when the database contains any, or null otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static StudentProfileTableList GetList(int SchoolKey)
        {
            return StudentProfileTableDB.GetList(SchoolKey);
        }

        /// <summary>
        /// Gets a single StudentProfileTable from the database without its data.
        /// </summary>
        /// <param name="studentProfileKey">The StudentProfileKey of the StudentProfileTable in the database.</param>
        /// <returns>A StudentProfileTable object when the StudentProfileKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentProfileTable GetItem(int studentProfileKey)
        {
            return GetItem(studentProfileKey, false);
        }

        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static StudentProfileTableList GetList(int SchoolKey, string Name, String Address, String NRICNO, string AddressType, string CountryCode, string CityCode, string DistrictCode)
        {
            return StudentProfileTableDB.GetList(SchoolKey, Name, Address, NRICNO, AddressType, CountryCode, CityCode, DistrictCode);
        }
        /// <summary>
        /// Gets a single StudentProfileTable from the database.
        /// </summary>
        /// <param name="studentProfileKey">The StudentProfileKey of the StudentProfileTable in the database.</param>
        /// <param name="getStudentProfileTableRecords">Determines whether to load all associated StudentProfileTable records as well.</param>
        /// <returns>
        /// A StudentProfileTable object when the StudentProfileKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentProfileTable GetItem(int studentProfileKey, bool getStudentProfileTableRecords)
        {
            StudentProfileTable myStudentProfileTable = StudentProfileTableDB.GetItem(studentProfileKey);
            return myStudentProfileTable;
        }

        /// <summary>
        /// Gets a single StudentProfileTable from the database.
        /// </summary>
        /// <param name="UserAccountKey">The UserAccountKey of the StudentProfileTable in the database.</param>
        /// <param name="getStudentProfileTableRecords">Determines whether to load all associated StudentProfileTable records as well.</param>
        /// <returns>
        /// A StudentProfileTable object when the UserAccountKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentProfileTable GetItemByUserAccountKey(int UserAccountKey)
        {
            StudentProfileTable myStudentProfileTable = StudentProfileTableDB.GetItemByUserAccountKey(UserAccountKey);
            return myStudentProfileTable;
        }

        /// <summary>
        /// Saves a StudentProfileTable in the database.
        /// </summary>
        /// <param name="myStudentProfileTable">The StudentProfileTable instance to save.</param>
        /// <returns>The new StudentProfileKey if the StudentProfileTable is new in the database or the existing StudentProfileKey when an item was updated.</returns>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public static int Save(StudentProfileTable myStudentProfileTable)
        {
            using (TransactionScope myTransactionScope = new TransactionScope())
            {
                int studentProfileTableStudentProfileKey = StudentProfileTableDB.Save(myStudentProfileTable);

                //  Assign the StudentProfileTable its new (or existing StudentProfileKey).
                myStudentProfileTable.StudentProfileKey = studentProfileTableStudentProfileKey;

                myTransactionScope.Complete();

                return studentProfileTableStudentProfileKey;
            }
        }

        /// <summary>
        /// Deletes a StudentProfileTable from the database.
        /// </summary>
        /// <param name="myStudentProfileTable">The StudentProfileTable instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(StudentProfileTable myStudentProfileTable)
        {
            return StudentProfileTableDB.Delete(myStudentProfileTable.StudentProfileKey);
        }

        /// <summary>
        /// Update Photo a StudentProfileTable from the database.
        /// </summary>
        /// <param name="myStudentProfileTable">The StudentProfileTable instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        public static bool UpdatePhoto(int StudentProfileKey, Byte[] imgPhoto)
        {
            return StudentProfileTableDB.UpdatePhoto(StudentProfileKey, imgPhoto);
        }

        /// <summary>
        /// Select Photo a StudentProfileTable from the database.
        /// </summary>
        /// <param name="myStudentProfileTable">The StudentProfileTable instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        public static Byte[] GetPhoto(int StudentProfileKey)
        {
            return StudentProfileTableDB.GetPhoto(StudentProfileKey);
        }

        #endregion

    }

}
